Stinga sgVersonInfo

Previous PageUp PageNext Page

FindVerInfo

© 1998 by Stinga

FindVerInfo Finds files which have specified string in the version information

Syntax

FindVerInfo path verinfo_name value

path - folder to be searched
verinfo_name - name of the version item to search
value - value to search for

Source code for this script follows:

On Error Resume Next
Dim sKey, sValue, sInfo, sMsg
Dim vbCrLf
vbCrLf = Chr(13) + Chr(10)

' Check arguments
if WScript.Arguments.Count <> 3 then
    WScript.Echo "Invalid command line. Expected: " + vbCrLf + _
                 "FindVerInfo path verinfo_name value"
    WScript.Quit(0)
end if

sKey = WScript.Arguments(1)
sValue = WScript.Arguments(2)

' Create some objects
set VerInfo = WScript.CreateObject("sgVersionInfo.VersionInfo")
Set fs = WScript.CreateObject("Scripting.FileSystemObject")
Set foldr = fs.GetFolder(WScript.Arguments(0))

' Are we running from command line
Dim bFromCmdLine
bFromCmdLine = false
if InStrRev(UCase(WScript.FullName), "CSCRIPT") then 
   bFromCmdLine = true
end if

' Scan all files in the folder
For Each File In foldr.Files

    ' Try to get version info for current file
    VerInfo.Path = File.Path
    if Err.Number = 0 then

        ' No error. Get specified info and see 
        ' if specified value is in it
        if VerInfo.InfoExist then
            sInfo = VerInfo.GetValue("StringFileInfo", sKey)
            if InStr(sInfo, sValue) > 0 then
                sMsg = file.Name + Chr(9) + VerInfo.FileVersion + _
                       Chr(9) + VerInfo.FileDescription
                if bFromCmdLine then
                    WScript.Echo sMsg
                else
                    rc = MsgBox(sMsg, 1)
                    if rc = 2 then WScript.Quit(0)
                end if
            end if
        end if
    else
        ' Somethig went wrong
        sMsg = file.Name + ": " + Err.Decription
        if bFromCmdLine then
            WScript.Echo sMsg
            MsgBox file.Name + ": " + Err.Decription
        else
            MsgBox sMsg
        end if
        Err.Clear
    end if
next

set VerInfo = nothing
Set fs = nothing
Set foldr = nothing

You can find several sample programs and scripts in the Samples subfolder of the SGVersionInfo installation folder.

 

Previous PageUp PageNext Page